import request from '../index';

export default {
  // 获取订单列表
  getList: (params) => request.get('/orders', params),
  
  // 获取订单详情
  getDetail: (id) => request.get(`/orders/${id}`),
  
  // 创建订单
  create: (data) => request.post('/orders', data),
  
  // 支付订单
  pay: (id, data) => request.post(`/orders/${id}/pay`, data),
  
  // 取消订单
  cancel: (id) => request.post(`/orders/${id}/cancel`),
  
  // 确认收货
  confirm: (id) => request.post(`/orders/${id}/confirm`),
  
  // 申请退款
  applyRefund: (id, data) => request.post(`/orders/${id}/refund`, data),
  
  // 评价订单
  rate: (id, data) => request.post(`/orders/${id}/rate`, data),
  
  // 删除订单
  delete: (id) => request.del(`/orders/${id}`),
  
  // 获取订单统计
  getStats: () => request.get('/orders/stats'),
  
  // 获取分销订单
  getDistributionOrders: (params) => request.get('/orders/distribution', params),
  
  // 获取配送信息
  getDeliveryInfo: (id) => request.get(`/orders/${id}/delivery`),
  
  // 更新配送地址
  updateDeliveryAddress: (id, data) => request.put(`/orders/${id}/delivery-address`, data),
  
  // 核销订单
  verify: (id, code) => request.post(`/orders/${id}/verify`, { code }),
  
  // 获取核销记录
  getVerifyRecords: (id) => request.get(`/orders/${id}/verify-records`),
  
  // 重新发货
  resend: (id) => request.post(`/orders/${id}/resend`),
  
  // 获取支付方式
  getPaymentMethods: () => request.get('/orders/payment-methods'),
  
  // 获取优惠券列表
  getAvailableCoupons: (id) => request.get(`/orders/${id}/available-coupons`),
  
  // 使用优惠券
  useCoupon: (id, data) => request.post(`/orders/${id}/use-coupon`, data),
  
  // 计算运费
  calculateShipping: (data) => request.post('/orders/calculate-shipping', data)
};